package com.pw.study.jdbc;

import com.pw.study.jdbc.pool.JdbcPool;

import java.io.IOException;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;

/**
 * @program: study_spring
 * @description: jdbc简单测试
 * @author: future
 * @create: 2021-03-23 21:24
 **/
public class MyHelloJDBC {

    public static void main(String[] args) {


        test1();
    }

    private static void test1() {

        Connection con1 = JdbcPool.getConnection();
        Connection con2 = JdbcPool.getConnection();
        Connection con3 = JdbcPool.getConnection();
        Connection con4 = JdbcPool.getConnection();
        Connection con5 = JdbcPool.getConnection();
        Connection con6 = JdbcPool.getConnection();
        Connection con7= JdbcPool.getConnection();
        Connection con8 = JdbcPool.getConnection();
        JdbcPool.returnConnection(con1);
        JdbcPool.returnConnection(con2);
        JdbcPool.returnConnection(con3);
        JdbcPool.returnConnection(con4);
        JdbcPool.returnConnection(con5);
        JdbcPool.returnConnection(con6);
        JdbcPool.returnConnection(con7);

    }

    private static void test() {
        try {
            Connection conn =JdbcPool.getConnection();
            Statement state = conn.createStatement();
            String sql ="SELECT * FROM student";
            ResultSet result =state.executeQuery(sql);
            while(result.next()){
                System.out.println(result.getString(1)+" "+result.getString(2));
            }

            result.close();
            state.close();
            conn.close();

        }catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }


}
